using DesktopApp.Models;
using DesktopApp.ViewModels; // Need this for RuleItemViewModel
using System.Collections.Generic;
using System.Threading.Tasks;

namespace DesktopApp.ViewModels.Services
{
    public interface IRuleManagementService
    {
        /// <summary>
        /// Loads rule processing templates from the default storage location.
        /// </summary>
        /// <returns>A list of loaded templates.</returns>
        Task<List<LogProcessingTemplate>> LoadTemplatesAsync();

        /// <summary>
        /// Saves the provided list of templates to the default storage location.
        /// </summary>
        /// <param name="templates">The templates to save.</param>
        Task SaveTemplatesAsync(IEnumerable<LogProcessingTemplate> templates);

        /// <summary>
        /// Loads the rules defined within a specific template.
        /// </summary>
        /// <param name="template">The template to load rules from.</param>
        /// <returns>A list of RuleItemViewModels representing the rules in the template.</returns>
        Task<List<RuleItemViewModel>> LoadRulesFromTemplateAsync(LogProcessingTemplate template);

        /// <summary>
        /// Prompts the user for a name and saves the current set of rules as a new template.
        /// </summary>
        /// <param name="currentRules">The list of rules to save.</param>
        /// <returns>The newly created template, or null if the operation was cancelled or failed.</returns>
        Task<LogProcessingTemplate?> SaveRulesAsTemplateAsync(IEnumerable<RuleItemViewModel> currentRules);

        /// <summary>
        /// Prompts the user for confirmation and deletes the specified template.
        /// </summary>
        /// <param name="templateToDelete">The template to delete.</param>
        /// <returns>True if the template was deleted, false otherwise.</returns>
        Task<bool> DeleteTemplateAsync(LogProcessingTemplate templateToDelete);

        /// <summary>
        /// Shows the rule editor to create a new rule.
        /// </summary>
        /// <returns>The newly created rule, or null if the operation was cancelled.</returns>
        Task<RuleItemViewModel?> AddRuleAsync();

        /// <summary>
        /// Shows the rule editor to modify an existing rule.
        /// </summary>
        /// <param name="ruleToEdit">The rule to edit.</param>
        /// <returns>A RuleItemViewModel containing the updated rule data, or null if the operation was cancelled.</returns>
        Task<RuleItemViewModel?> EditRuleAsync(RuleItemViewModel ruleToEdit);

        /// <summary>
        /// Prompts the user for confirmation and prepares a rule for deletion.
        /// Note: The actual removal from the collection happens in the ViewModel.
        /// </summary>
        /// <param name="ruleToDelete">The rule to delete.</param>
        /// <returns>True if the deletion was confirmed, false otherwise.</returns>
        Task<bool> ConfirmDeleteRuleAsync(RuleItemViewModel ruleToDelete);

        // --- Add Rule Set Methods ---

        /// <summary>
        /// Loads rule sets from the default storage location.
        /// </summary>
        /// <returns>A list of loaded rule sets.</returns>
        Task<List<RuleSet>> LoadRuleSetsAsync();

        /// <summary>
        /// Saves the provided list of rule sets to the default storage location.
        /// </summary>
        /// <param name="ruleSets">The rule sets to save.</param>
        Task SaveRuleSetsAsync(IEnumerable<RuleSet> ruleSets);
    }
} 